package com.ibeacon.controller.common;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

public class InitServlet extends HttpServlet {  
	Log log = Log.getLogger();
    private static final long serialVersionUID = 1L;    
    
    public void init() throws ServletException {    
        // 获取info.xml中配置的参数    
        TokenThread.appid =  MessageManager.getMsg("appid");// "wxb44f389e6eaf1917";
        TokenThread.appsecret =  MessageManager.getMsg("appsecret");// "e2be14e6b1992acd730187ed85e6f1ad";
    
        log.logger.info("weixin api appid:"+TokenThread.appid);    
        log.logger.info("weixin api appsecret:"+TokenThread.appsecret);    
        // 未配置appid、appsecret时给出提示
        if ("".equals(TokenThread.appid) || "".equals(TokenThread.appsecret)) {    
        	log.logger.error("appid and appsecret configuration error, please check carefully.");    
        } else {    
            // 启动定时获取access_token的线程    
            new Thread(new TokenThread()).start();    
        }    
    }    
} 